package com.abel.bigwater.dataserver.model.ewide

import io.netty.buffer.ByteBuf

class TermReplySpecifyData(_pduLen: Int = -1) : TermData(KmingDataType.ReqSpecificData, _pduLen) {

    var respondType: SessionReponseType? = SessionReponseType.Success

    var frameCount: Int? = null

    override fun bufLength() = 1 + 1 + 2

    override fun parseBuf(buf: ByteBuf): Boolean {
        assert(type == KmingDataType.findByCode(buf.readUnsignedByte()))
        respondType = SessionReponseType.findByCode(buf.readByte())

        frameCount = buf.readUnsignedShortLE()

        return true
    }

    override fun pack(buf: ByteBuf) {
        buf.writeByte(type.code.toInt())
        buf.writeByte(respondType!!.code.toInt())
        buf.writeShortLE(frameCount!!)
    }
}